package com.jie.langlangmall.controller;

import com.jie.langlangmall.common.api.CommonPage;
import com.jie.langlangmall.common.api.CommonResult;
import com.jie.langlangmall.dto.OmsOrderReturnApplyResult;
import com.jie.langlangmall.dto.OmsReturnApplyQueryParam;
import com.jie.langlangmall.dto.OmsUpdateStatusParam;
import com.jie.langlangmall.model.OmsOrderReturnApply;
import com.jie.langlangmall.service.OmsOrderReturnApplyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author Jie
 * @Date 2024/11/28
 * @Email 3217998214@qq.com
 * @Description 退货申请
 */
@RestController
@Tag(name = "OmsOrderReturnApplyController", description = "订单退货申请管理")
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {

    @Autowired
    private OmsOrderReturnApplyService returnApplyService;

    @Operation(summary = "分页查询退货申请")
    @GetMapping("/list")
    public CommonResult<CommonPage<OmsOrderReturnApply>> list(OmsReturnApplyQueryParam queryParam,
                                                              @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<OmsOrderReturnApply> returnApplyList = returnApplyService.list(queryParam, pageSize, pageNum);
        return CommonResult.success(CommonPage.restPage(returnApplyList));
    }

    @Operation(summary = "批量删除退货申请")
    @PostMapping("/delete")
    public CommonResult<?> delete(@RequestParam("ids") List<Long> ids) {
        returnApplyService.delete(ids);
        return CommonResult.success();
    }

    @Operation(summary = "获取退货申请详情")
    @GetMapping("/{id}")
    public CommonResult<?> getItem(@PathVariable Long id) {
        OmsOrderReturnApplyResult result = returnApplyService.getItem(id);
        return CommonResult.success(result);
    }

    @Operation(summary = "修改退货申请状态")
    @PostMapping("/update/status/{id}")
    public CommonResult<?> updateStatus(@PathVariable Long id, @RequestBody OmsUpdateStatusParam statusParam) {
        returnApplyService.updateStatus(id, statusParam);
        return CommonResult.success();
    }
    

}